package service;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public abstract class PaymentCheck {
	private Date lastPayDay;
	private int PayDay=Calendar.FRIDAY;
	//it's a day of the week define use Calendar
	public PaymentCheck(Date lastPayDay){
		this.lastPayDay=lastPayDay;
	}
	public abstract boolean checkPay();
	public int getPayDay() {
		return PayDay;
	}
	public void setPayDay(int payDay) {
		PayDay = payDay;
	}
	public Date getLastPayDay() {
		return lastPayDay;
	}
	public void setLastPayDay(Date lastPayDay) {
		this.lastPayDay = lastPayDay;
	}
	public boolean alreadyPayToday(){
		DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
		Date todayDate=null;
		try {
			todayDate = format.parse(format.format(Calendar.getInstance().getTime()));
		} catch (ParseException e) {
			e.printStackTrace();
		}
		if(lastPayDay==null||(lastPayDay!=null&&todayDate.after(lastPayDay))){
			return true;
		}
		return false;
	}
}
